#pragma once
#include <set>
#include <vector>

std::multiset <void *> all_ptr;

void dec (void *p)
{
	if (all_ptr.count(p) > 0)
		all_ptr.erase(p);
}

void inc (void *p)
{
	all_ptr.insert(p);
}

std::vector <void *> collect ()
{
	void * cur = 0;
	std::vector <void *> res;
	for (std::multiset <void *>::iterator it = all_ptr.begin(); it != all_ptr.end(); it++)
	{
		if (*it != cur)
		{
			if (cur != 0)
				res.push_back(cur);
			cur = *it;
		}
	}
	if (cur != 0)
		res.push_back(cur);
	return res;
}
